import React from 'react'
import { Select } from 'antd';
import { useTranslation } from 'react-i18next';
function Index() {
    const {t,i18n}=useTranslation()
    const yu=localStorage.getItem('yu')||i18n.language||'zh'
    const handleChange = (value:string) => {
        const htmlNode=document.documentElement
        htmlNode.setAttribute('theme',value)
        localStorage.setItem('data-theme',value)
      };
    const  theme=localStorage.getItem('dark')||'light'
    const handleChanges = (value:string) => {
        i18n.changeLanguage(value)
        localStorage.setItem('yu',value)
      };
  return (
    <div  className='' >
         <Select
      defaultValue={theme}
      style={{ width: 120 }}
      onChange={handleChanges}
      options={[
        { value: 'white', label: '白天' },
        { value: 'dark', label: '黑夜' },
        { value: 'white', label: '白天' },
      ]}
    />
     <Select
      defaultValue={yu}
      style={{ width: 120 }}
      onChange={handleChange}
      options={[
        { value: 'zh', label: '中文' },
        { value: 'en', label: '英文' },
      ]}
    />
    <h1>{t('Welcome to React')}</h1>
    </div>
  )
}

export default Index
